home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / python-support / python-gdata / gdata / client.py < prev    next >
Encoding:
Python Source  |  2009-01-22  |  3.2 KB  |  102 lines

  1. #!/usr/bin/python
  2. #
  3. # Copyright (C) 2008 Google Inc.
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. #      http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16.  
  17.  
  18. __author__ = 'j.s@google.com (Jeff Scudder)'
  19.  
  20.  
  21. import atom.client
  22.  
  23.  
  24. # Old imports
  25. import urllib
  26. import urlparse
  27. import gdata.auth
  28. import gdata.service
  29. import atom.service
  30.  
  31.  
  32. class GDClient(atom.client.AtomPubClient):
  33.   pass
  34.  
  35.  
  36. SCOPE_URL_PARAM_NAME = gdata.service.SCOPE_URL_PARAM_NAME 
  37. # Maps the service names used in ClientLogin to scope URLs. 
  38. CLIENT_LOGIN_SCOPES = gdata.service.CLIENT_LOGIN_SCOPES
  39.  
  40.  
  41. class AuthorizationRequired(gdata.service.Error):
  42.   pass
  43.  
  44.  
  45. class GDataClient(gdata.service.GDataService):
  46.   """This class is deprecated. 
  47.   
  48.   All functionality has been migrated to gdata.service.GDataService.
  49.   """
  50.   def __init__(self, application_name=None, tokens=None):
  51.     gdata.service.GDataService.__init__(self, source=application_name, 
  52.         tokens=tokens)
  53.  
  54.   def ClientLogin(self, username, password, service_name, source=None, 
  55.       account_type=None, auth_url=None, login_token=None, login_captcha=None):
  56.     gdata.service.GDataService.ClientLogin(self, username=username, 
  57.         password=password, account_type=account_type, service=service_name,
  58.         auth_service_url=auth_url, source=source, captcha_token=login_token,
  59.         captcha_response=login_captcha)
  60.  
  61.   def Get(self, url, parser):
  62.     """Simplified interface for Get.
  63.  
  64.     Requires a parser function which takes the server response's body as
  65.     the only argument.
  66.  
  67.     Args:
  68.       url: A string or something that can be converted to a string using str.
  69.           The URL of the requested resource.
  70.       parser: A function which takes the HTTP body from the server as it's
  71.           only result. Common values would include str, 
  72.           gdata.GDataEntryFromString, and gdata.GDataFeedFromString.
  73.  
  74.     Returns: The result of calling parser(http_response_body).
  75.     """
  76.     return gdata.service.GDataService.Get(self, uri=url, converter=parser)
  77.  
  78.   def Post(self, data, url, parser, media_source=None):
  79.     """Streamlined version of Post.
  80.  
  81.     Requires a parser function which takes the server response's body as
  82.     the only argument.
  83.     """
  84.     return gdata.service.GDataService.Post(self, data=data, uri=url,
  85.         media_source=media_source, converter=parser)
  86.  
  87.   def Put(self, data, url, parser, media_source=None):
  88.     """Streamlined version of Put.
  89.  
  90.     Requires a parser function which takes the server response's body as
  91.     the only argument.
  92.     """
  93.     return gdata.service.GDataService.Put(self, data=data, uri=url,
  94.         media_source=media_source, converter=parser)
  95.  
  96.   def Delete(self, url):
  97.     return gdata.service.GDataService.Delete(self, uri=url)
  98.  
  99.  
  100. ExtractToken = gdata.service.ExtractToken
  101. GenerateAuthSubRequestUrl = gdata.service.GenerateAuthSubRequestUrl    
  102.